﻿
@{
    ViewData["Title"] = "Index";
}

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 资讯管理 <span class="c-gray en">&gt;</span> 大赛介绍 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <form class="ajaxTable" data-target="table">
        <div class="text-c">
            日期范围：
            <input type="text" name="startDate" onfocus="WdatePicker({ maxDate: '#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}' })" id="logmin" class="input-text Wdate" style="width: 120px;">
            -
            <input type="text" name="endDate" onfocus="WdatePicker({ minDate: '#F{$dp.$D(\'logmin\')}', maxDate: '%y-%M-%d' })" id="logmax" class="input-text Wdate" style="width: 120px;">
            <input type="text" name="title" id="" placeholder=" 名称" style="width: 250px" class="input-text">
            <button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </div>
    </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"> <a class="btn btn-primary radius ajaxLink" data-title="添加" data-href="@Url.Action("Create", "Introduction")" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加</a></span> </div>
    <div class="mt-20">
        <table class="layui-table" lay-data="{url: '@Url.Action("DataJson", "Introduction")',height:'full-320',id:'table',page: true,limits: [10, 20,50]}" lay-filter="table" id="table">
            <thead>
                <tr>
                    <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                    <th lay-data="{field:'id', width:80, sort: true}">ID</th>
                    <th lay-data="{field:'title', width:580}">标题</th>
                    <th lay-data="{field:'classId', width:280}">类型</th>
                    <th lay-data="{field:'addTime', width:280,sort: true}">添加时间</th>
                    <th lay-data="{field:'status', templet: '#checkboxTpl', unresize: true}">状态</th>
                    <th lay-data="{field:'operation',fixed: 'right', width:150,sort: false, toolbar: '#barDemo'}">操作</th>
                </tr>
            </thead>
        </table>
        <script type="text/html" id="checkboxTpl">
            <input type="checkbox" name="lock" data-id="{{d.id}}" value="{{d.status}}" title="有效" lay-filter="lockDemo" {{ d.status == 1 ? 'checked' : '' }}>
        </script>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        </script>
    </div>
</div>
@section Scripts{
    <script type="text/javascript">
        //引用lay-ui的table控件
        layui.use('table', function () {
            var table = layui.table
                ,form = layui.form;

            //监听工具条
            table.on('tool(table)', function(obj){
                var data = obj.data;
                if (obj.event == 'edit'){
                    var url = '@Url.Action("Edit", "Introduction")/' + data.id;
                    layer_full("编辑", url);
                } else if (obj.event == 'del') {
                    layer.confirm('确认要删除吗？', function(index) {
                        ajaxAntiForgery('@Url.Action("Delete", "Introduction")', { Id: data.id });
                    });

                }
            });

            //监听锁定操作
            form.on('checkbox(lockDemo)', function (obj) {
                ajaxAntiForgery('@Url.Action("Lock", "Introduction")', { Id: $(this).data("id"), Checked: obj.elem.checked });
            });
        });
    </script>

}